package com.xueshishasha.oa.business.Command
{
	import com.adobe.cairngorm.commands.Command;
	import com.adobe.cairngorm.control.CairngormEvent;
	import com.xueshishasha.oa.VO.PageModel;
	import com.xueshishasha.oa.business.Delegate.EmployeeDelegate;
	import com.xueshishasha.oa.business.Event.GetAllEmployeeEvent;
	import com.xueshishasha.oa.model.OAModelLocator;
	
	import mx.controls.Alert;
	import mx.rpc.IResponder;
	import mx.rpc.events.FaultEvent;
	import mx.rpc.events.ResultEvent;
	
	public class GetAllEmployeeCommand  implements Command,IResponder
	{
		private var _model :OAModelLocator = OAModelLocator.getInstance();
 
		public function GetAllEmployeeCommand()
		{
		}
		
		public function execute(event:CairngormEvent):void
		{
			var e : GetAllEmployeeEvent = GetAllEmployeeEvent(event);			

			var emloyeeDelegate:EmployeeDelegate = new EmployeeDelegate(this);

			emloyeeDelegate.getAllEmployee(e.p);
			Alert.show("执行到GetAllEmployeeCommand.EXECUTE()");							
		}

		public function result(data:Object):void{
			var event:ResultEvent = data as ResultEvent;
			
			Alert.show("返回数据");							
			_model.pageModel = event.result as PageModel;//转换为PageModel
			
		}
		
		public function fault(data:Object):void{
			var event:FaultEvent = data as FaultEvent;
			Alert.show("获得数据错误");							
			
		}

	}
}